package com.example.eschool;

import androidx.appcompat.app.AppCompatActivity;

import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.Toast;

public class ESchoolLogin extends AppCompatActivity implements View.OnClickListener{
    EditText edit_1,edit_2;
    Button btu_1;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.eschool_login);
        initView();
        btu_1.setOnClickListener(this);
    }

    private void initView() {
        btu_1 = findViewById(R.id.btn_Login);
        edit_1 = findViewById(R.id.edit_1);
        edit_2 = findViewById(R.id.edit_2);
    }

    public void login(){
        Intent intent = new Intent(ESchoolLogin.this, MainActivity.class);
        startActivity(intent);
    }

    @Override
    public void onClick(View v) {
        if(v.getId() == R.id.btn_Login){
            String username = edit_1.getText().toString();
            String password = edit_2.getText().toString();
            if(username.equals("admin") && password.equals("admin123")){
                login();
            }else{
                Toast.makeText(ESchoolLogin.this,"账号或者密码错误，请重新输入",Toast.LENGTH_LONG).show();
            }

        }
    }
}